package org.chaos.sekiro.common.ktorm

import org.ktorm.entity.Entity
import org.ktorm.schema.Table
import org.ktorm.schema.datetime
import kotlin.reflect.KClass

abstract class AuditTable<T: Entity<T>>(
    tableName: String,
    alias: String? = null,
    catalog: String? = null,
    schema: String? = null,
    entityClass: KClass<T>? = null
) : Table<T>(tableName, alias, catalog, schema, entityClass) {

    val createdTime = datetime("created_time").bindTo { (it as AuditEntity).createdTime }
    val modifiedTime = datetime("modified_time").bindTo { (it as AuditEntity).modifiedTime }
}